<?php
namespace Home\Controller;
use Home\Controller\BaseController;
class LoginController extends BaseController {
	public function _initialize(){
		//parent::_initialize();
	}
	public function dologin(){
		$map=array(
			"phone"=>I('post.phone'),
			"password"=>md5(I('post.pass'))
		);
		$user=M("users")->where($map)->find();
		if($user){
			session('user',$user);
			 echo "<script>alert('登录成功！');window.location.href=document.referrer;</script>";//返回并刷新
			//$this->success('登录成功',U("Index/index"));
		}else{
			echo "<script>alert('登录失败！');window.location.href=document.referrer;</script>";//返回并刷新
		}
	}
	public function logout(){
		//var_dump($_SESSION['user']);exit;
		session('user',null);
		//echo "<script>alert('注销成功！');window.location.href=document.referrer;</script>";//返回并刷新
		$this->redirect('Index/index');
	}
}
?>